package custom.Delivel;

//import ai.group_template.L2AttackableAIScript;
import com.l2jserver.gameserver.model.actor.L2Npc;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.model.base.Experience;
import com.l2jserver.gameserver.model.quest.Quest;
import com.l2jserver.gameserver.model.quest.QuestState;
import com.l2jserver.gameserver.model.quest.State;

@SuppressWarnings("unused")
public class Delivel extends Quest
{
	public Delivel(int id,String name,String descr)
	{
		super(id,name,descr);
		// int mob = 8005;
		//this.registerMobs(mob);
		addStartNpc(8005);
		addFirstTalkId(8005);
		addTalkId(8005);
	}
	
	public String onTalk(L2Npc npc, L2PcInstance player)
	{
		QuestState st = player.getQuestState("Delivel");
		if (player.isSubClassActive()) 
		{
			if (player.getStat().getLevel() <= 40) 
			{
				return "<html><body>You cannot be under level 40 when you are in a subclass</html>";
			}
		}
		byte lvl = (byte) (player.getLevel()-1);
		if (lvl >= 1 && lvl <= Experience.MAX_LEVEL)
		{
			if (player.getAdena() > 10000)
			{
				long pXp = player.getExp();
				long tXp = Experience.LEVEL[lvl];
				player.removeExpAndSp(pXp - tXp, 0);
				st.takeItems(57,10000);
			}
			else
				return "<html><body>You have not enough adena</html>";
		}
		return super.onTalk(npc, player);	
	}
	
	public String onFirstTalk(L2Npc npc, L2PcInstance player)
	{
		QuestState st = player.getQuestState("Delivel");
			if (st == null) 
				st = this.newQuestState(player);
		st.setState(State.STARTED);
		return "8005.htm";
		//return super.onFirstTalk(npc, player);	
	}
	
	public String onAdvEvent (String event, L2Npc npc, L2PcInstance player)
	{
		QuestState st = player.getQuestState("Delivel");
		if (event.equalsIgnoreCase("del"))
		{
			return "8005-1.htm";
		}
		return super.onAdvEvent(event, npc, player);	
	}

	public static void main(String[] args)
	{
		// now call the constructor (starts up the ai)
		new Delivel(-1,"Delivel","custom");
	}			
}